#!/bin/bash

LOGFILE=`date +"/var/log/qrpbbb/%Y%m%d-%H%M.iwant"`
LOCK=/tmp/qrpbbb_iwant
trap 'rm -f ${LOCK} ; exit 1' 1 2 3 15

if /usr/lib/news/bin/shlock -p $$ -f ${LOCK}
then
    /root/qrpbbb/qrpbbb_iwant.py  2>&1 >${LOGFILE}

    #if nothing interesting, remove
    n=`cat ${LOGFILE}|egrep -v "^qrpbbb"|grep -v "^$"|wc -l`
    if [ "x"$n == "x0" ]; then rm -f ${LOGFILE}; fi
fi

rm -f ${LOCK}
